package com.example.imageloader2002.impl;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.example.imageloader2002.IImageLoader;
import com.example.imageloader2002.ImageOptions;

public class GlideImpl implements IImageLoader {
    @Override
    public void loadImage(Context context, Object res, ImageOptions options, ImageView target) {
        RequestBuilder<Drawable> builder = null;
        builder = Glide.with(context).load(res);

        if(options!=null){
            if(options.getPlaceImage()>0){
                builder.placeholder(options.getPlaceImage());
            }
            if(options.getErrorImage()>0){
                builder.error(options.getErrorImage());
            }
        }
        builder.into(target);
    }
}
